<?php
	/* Description: This file is used to edit main category. */
	#########IncludeFiles####################################################################################
	include_once '../inc/config.php';
	include_once("../inc/bootstrape.php");
	require_once _SITE_PATH_.'classes/Vendor/Vendor.php';
	require_once _SITE_PATH_.'classes/Category/Category.php';
	require_once _SITE_PATH_.'classes/CommonUtility/CommonUtility.php';
	
	$id = trim($_REQUEST['id']); 
	if( $_POST['submit']=='Submit'){  
		$parms['id'] = $_POST['id'];
		$parms['name'] = $_POST['name'];
		$parms['parent_id'] = 0;
		$parms['added'] = date("Y-m-d h:i:s");
		$parms['modified'] = date("Y-m-d h:i:s");;
			   
		$condition = array(); 
		$condition['id'] = $parms['id'];
		if( CommonUtility::updateData($parms, 'category', $condition)) {       
			header("Location: category_mng.php?msg=1086");            
			exit;
		}
		$err = 1087;    
	}
	$categories = array();	
	$categories = Category::getMainCategories($id);
	$result = $categories[0];
	
	
	$errMsg = $err;
	$_tplName = 'category/category_edit.tpl';
	$_title = 'Edit Category';

	require_once _ADMIN_TPL_MAIN_;
?>